home *** CD-ROM | disk | FTP | other *** search
/ The Complete Utilities To…ka 501 Killer Utilities! / 501 Killer Utilities! (Macworld July 1995).cdr / Programming / OutOfPhase1.1 Source / OutOfPhase Folder / ASTExpression.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-27  |  5.8 KB  |  165 lines  |  [TEXT/KAHL]

  1. /* ASTExpression.h */
  2.  
  3. #ifndef Included_ASTExpression_h
  4. #define Included_ASTExpression_h
  5.  
  6. /* ASTExpression module depends on */
  7. /* MiscInfo.h */
  8. /* Audit */
  9. /* Debug */
  10. /* Definitions */
  11. /* TrashTracker */
  12. /* Memory */
  13. /* PcodeObject */
  14. /* CompilerRoot */
  15. /* ASTArrayDeclaration */
  16. /* ASTAssignment */
  17. /* ASTBinaryOperator */
  18. /* ASTConditional */
  19. /* ASTExpressionList */
  20. /* ASTFuncCall */
  21. /* ASTLoop */
  22. /* ASTOperand */
  23. /* ASTUnaryOperator */
  24. /* ASTVariableDeclaration */
  25. /* ASTPrintString */
  26. /* ASTPrintExpr */
  27. /* SymbolTableEntry */
  28.  
  29. #include "PcodeObject.h"
  30. #include "CompilerRoot.h"
  31.  
  32. struct ASTExpressionRec;
  33. typedef struct ASTExpressionRec ASTExpressionRec;
  34.  
  35. /* all memory allocated in this module is through TrashTracker */
  36.  
  37. typedef enum
  38.     {
  39.         eExprArrayDeclaration EXECUTE(= -9769),
  40.         eExprAssignment,
  41.         eExprBinaryOperator,
  42.         eExprConditional,
  43.         eExprExpressionList,
  44.         eExprFunctionCall,
  45.         eExprLoop,
  46.         eExprOperand,
  47.         eExprUnaryOperator,
  48.         eExprVariableDeclaration,
  49.         eExprErrorForm,
  50.         eExprWaveGetter,
  51.         eExprPrintString,
  52.         eExprPrintExpr
  53.     } ExprTypes;
  54.  
  55. /* forwards */
  56. struct TrashTrackRec;
  57. struct ASTArrayDeclRec;
  58. struct ASTAssignRec;
  59. struct ASTBinaryOpRec;
  60. struct ASTCondRec;
  61. struct ASTExprListRec;
  62. struct ASTFuncCallRec;
  63. struct ASTLoopRec;
  64. struct ASTOperandRec;
  65. struct ASTUnaryOpRec;
  66. struct ASTVarDeclRec;
  67. struct ASTErrorFormRec;
  68. struct ASTWaveGetterRec;
  69. struct ASTPrintStringRec;
  70. struct ASTPrintExprRec;
  71. struct SymbolRec;
  72.  
  73. /* construct a generic expression around an array declaration */
  74. ASTExpressionRec*        NewExprArrayDecl(struct ASTArrayDeclRec* TheArrayDeclaration,
  75.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  76.  
  77. /* construct a generic expression around an assignment statement */
  78. ASTExpressionRec*        NewExprAssignment(struct ASTAssignRec* TheAssignment,
  79.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  80.  
  81. /* construct a generic expression around a binary operator */
  82. ASTExpressionRec*        NewExprBinaryOperator(struct ASTBinaryOpRec* TheBinaryOperator,
  83.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  84.  
  85. /* construct a generic expression around a conditional. */
  86. ASTExpressionRec*        NewExprConditional(struct ASTCondRec* TheConditional,
  87.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  88.  
  89. /* construct a generic expression around a list of expressions. */
  90. ASTExpressionRec*        NewExprSequence(struct ASTExprListRec* TheExpressionList,
  91.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  92.  
  93. /* construct a generic expression around a function call */
  94. ASTExpressionRec*        NewExprFunctionCall(struct ASTFuncCallRec* TheFunctionCall,
  95.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  96.  
  97. /* construct a generic expression around a loop */
  98. ASTExpressionRec*        NewExprLoop(struct ASTLoopRec* TheLoop,
  99.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  100.  
  101. /* construct a generic expression around an operand */
  102. ASTExpressionRec*        NewExprOperand(struct ASTOperandRec* TheOperand,
  103.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  104.  
  105. /* construct a generic expression around a unary operator */
  106. ASTExpressionRec*        NewExprUnaryOperator(struct ASTUnaryOpRec* TheUnaryOperator,
  107.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  108.  
  109. /* construct a generic expression around a variable declaration */
  110. ASTExpressionRec*        NewExprVariableDeclaration(struct ASTVarDeclRec* TheVariableDecl,
  111.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  112.  
  113. /* construct a generic expression around an error form */
  114. ASTExpressionRec*        NewExprErrorForm(struct ASTErrorFormRec* TheErrorForm,
  115.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  116.  
  117. /* construct a generic expression around a wave getter */
  118. ASTExpressionRec*        NewExprWaveGetter(struct ASTWaveGetterRec* TheWaveGetter,
  119.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  120.  
  121. /* construct a generic expression around an error form */
  122. ASTExpressionRec*        NewExprPrintString(struct ASTPrintStringRec* ThePrintString,
  123.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  124.  
  125. /* construct a generic expression around an error form */
  126. ASTExpressionRec*        NewExprPrintExpr(struct ASTPrintExprRec* ThePrintExpr,
  127.                                             struct TrashTrackRec* TrashTracker, long TheLineNumber);
  128.  
  129.  
  130. /* type check an expression.  returns eCompileNoError and the resulting value */
  131. /* type if it checks correctly. */
  132. CompileErrors                TypeCheckExpression(DataTypes* ResultTypeOut,
  133.                                             ASTExpressionRec* TheExpression, long* ErrorLineNumber,
  134.                                             struct TrashTrackRec* TrashTracker);
  135.  
  136. /* get a symbol table entry out of an expression.  this is used for getting */
  137. /* function generation stuff. */
  138. CompileErrors                ExpressionGetFunctionCallSymbol(struct SymbolRec** SymbolOut,
  139.                                             ASTExpressionRec* TheExpression);
  140.  
  141. /* find out if the expression is a valid lvalue */
  142. MyBoolean                        IsExpressionValidLValue(ASTExpressionRec* TheExpression);
  143.  
  144. /* find out what kind of expression it is */
  145. ExprTypes                        WhatKindOfExpressionIsThis(ASTExpressionRec* TheExpression);
  146.  
  147. /* generate code for any expression.  returns True if successful, or False if it fails. */
  148. MyBoolean                        CodeGenExpression(struct PcodeRec* FuncCode, long* StackDepthParam,
  149.                                             ASTExpressionRec* Expression);
  150.  
  151. /* get the operand from the generic expression */
  152. struct ASTOperandRec*    GetOperandOutOfExpression(ASTExpressionRec* TheExpression);
  153.  
  154. /* get the binary operator out of the generic expression */
  155. struct ASTBinaryOpRec*    GetBinaryOperatorOutOfExpression(ASTExpressionRec* TheExpression);
  156.  
  157. /* get the type of value that is returned by this expression */
  158. DataTypes                        GetExpressionsResultantType(ASTExpressionRec* TheExpression);
  159.  
  160. /* generate code for an expression.  returns True if successful, or False if it fails. */
  161. MyBoolean                        CodeGenExpression(struct PcodeRec* FuncCode,
  162.                                             long* StackDepthParam, ASTExpressionRec* Expression);
  163.  
  164. #endif
  165.